using UnityEngine;
using System.Collections;

public class FlareController : MonoBehaviour {
	public float Duration;
	float lifetime;
	float range;
	float intensity;
	
	// Use this for initialization
	void Awake () {
		light.range = 100.0f;
		light.intensity = 8.0f;
		range = light.range;
		intensity = light.intensity;
		lifetime = 0.0f;
	}
	
	// Update is called once per frame
	void Update () {
		float level = ( Duration - lifetime ) / Duration;
		light.range = ( range / 2 ) +  ( ( range * level ) * 0.5f );
		light.intensity = intensity * level;
		lifetime += Time.deltaTime;

		if( lifetime > Duration )
			Destroy( gameObject );
	}
}
